<template>
   
  <div class="order">
    <headcamp :back="$route.meta.back" :title="$route.meta.title"></headcamp>

    <div class="box">
      <!-- //地址列表 -->
      <van-address-edit
        :area-list="areaList"
        show-set-default
        show-search-result
        :search-result="searchResult"
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
        @change-detail="onChangeDetail"
      />
    </div>
  </div>
</template>

<script>
import { areaList } from "@vant/area-data";
export default {
  data() {
    return {
      uid: this.$utils.getuid(),
      areaList,
      searchResult: [],
    };
  },
  methods: {
    //点击保存时触发
    onSave(val) {
      console.log(val);
      let box={
          uid:this.uid,
          username:val.name,
          userphone:val.tel,
          regioncode:val.areaCode,
          location:val.county+val.county,
          useraddress:val.addressDetail,
          status:val.isDefault 
      }
      this.$api.address(box).then(res=>{
         this.$router.push('/addresslist')
      })

    },
    //修改时触发
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区",
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
  },
  created() {},
  mounted() {},
  components: {},
  computed: {},
  watch: {},
};
</script>

<style lang='less' scoped>
.order {
  width: 100%;
  height: 100%;
}
.box {
  padding-top: 80px;
}
</style>
